Page({
  data: {
    imageList: [],
    videoList: [],
    audioPath: '',
    textContent: '',
    isPlaying: false,
    recipient: '',
    Sender: '',
    Time: ''
  },

  onLoad(options) {

    const eventChannel = this.getOpenerEventChannel();
    eventChannel.on('acceptDataFromOpenerPage', (data) => {
      this.setData({
        imageList: data.imageList,
        videoList: data.videoList,
        audioPath: data.audioPath,
        textContent: data.textContent,
        recipient: data.recipient,
        Sender: data.Sender,
        Time: data.Time
      });
    });
   
  },

  togglePlayRecording() {
    const innerAudioContext = wx.createInnerAudioContext();
    innerAudioContext.src = this.data.audioPath;

    if (this.data.isPlaying) {
      innerAudioContext.stop();
      this.setData({ isPlaying: false });
    } else {
      innerAudioContext.play();
      this.setData({ isPlaying: true });
    }

    innerAudioContext.onEnded(() => {
      this.setData({ isPlaying: false });
    });

    innerAudioContext.onStop(() => {
      this.setData({ isPlaying: false });
    });
  }
});
